package com.mfl.controller.admin;

import com.mfl.common.PageResult;
import com.mfl.common.Result;
import com.mfl.mapper.ExamMapper;
import com.mfl.pojo.dto.ExamDetailPageQueryDTO;
import com.mfl.pojo.dto.ExamPageQueryDTO;
import com.mfl.service.ExamDetailService;
import com.mfl.service.ExamService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController("adminExamController")
@RequestMapping("/cky/admin/exam")
@Slf4j
public class ExamController {

    @Autowired
    private ExamService examService;
    @Autowired
    private ExamDetailService examDetailService;

    /**
     * 分页查询考试记录
     * @param examPageQueryDTO
     * @return
     */
    @GetMapping("/page")
    public Result<PageResult> page(ExamPageQueryDTO examPageQueryDTO){
        log.info("分页查询考试记录：{}", examPageQueryDTO);
        PageResult pageResult = examService.pageQuery(examPageQueryDTO);
        return Result.success("", pageResult);
    }

    /**
     * 分页查询考试记录详情
     * @param examDetailPageQueryDTO
     * @return
     */
    @GetMapping("/detail/page")
    public Result<PageResult> page(ExamDetailPageQueryDTO examDetailPageQueryDTO){
        log.info("分页查询考试记录详情：{}", examDetailPageQueryDTO);
        PageResult pageResult = examDetailService.pageQuery(examDetailPageQueryDTO);
        return Result.success("", pageResult);
    }

    /**
     * 批量删除考试记录
     * @param ids
     * @return
     */
    @DeleteMapping("/batchDelete")
    public Result batchDelete(@RequestParam List<Integer> ids){
        log.info("批量删除考试记录：{}", ids);
        examService.batchDelete(ids);
        return Result.success("删除成功");
    }
}
